/*

Esta clase controla el funcionamiento del polhemus

*/

#ifndef _POLHEMUSCONTROL_H

#define _POLHEMUSCONTROL_H

#if defined (_WIN32)
#include <windows.h>
#include "IncludePolhemus/PDI.h"
#endif

#if defined (__linux__)
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <string.h>
#include <strings.h>

#include "vrpn/vrpn_Shared.h"
#include "vrpn/vrpn_Tracker.h"
#include "vrpn/vrpn_Button.h"
#include "vrpn/vrpn_Analog.h"
#include "vrpn/vrpn_Dial.h"
#endif

class polhemusControl
{
public:
	//Contructor
	polhemusControl();
	polhemusControl(const polhemusControl &pC);

private:
#if defined (_WIN32)
	//Atributos
	// Variables Polhemus
	CPDIdev		*g_pdiDev;
	CPDImdat    g_pdiMDat;
	CPDIser		g_pdiSer;
	DWORD		g_dwFrameSize;
	BOOL		g_bCnxReady;
	DWORD		g_dwStationMap;
	LPCSTR		g_Datos;
        bool isOpen;
#endif
        float x1, y1, z1, rx1, ry1, rz1;
	float x2, y2, z2, rx2, ry2, rz2;
#if defined (__linux__)
        static polhemusControl *p;
        //vrpn_Tracker_Remote *tkr;
#endif
        
	//Atributos
public:
 
	//Sensor 1
	float get_x1(){return x1;}
	float get_y1(){return y1;}
	float get_z1(){return z1;}

	float get_rx1(){return rx1;}
	float get_ry1(){return ry1;}
	float get_rz1(){return rz1;}

        void set_x1(float f){x1 = f;}
        void set_y1(float f){y1 = f;}
	void set_z1(float f){z1 = f;}

	void set_rx1(float f){rx1 = f;}
	void set_ry1(float f){ry1 = f;}
	void set_rz1(float f){rz1 = f;}
        
	//Sensor 2
	float get_x2(){return x2;}
	float get_y2(){return y2;}
	float get_z2(){return z2;}

	float get_rx2(){return rx2;}
	float get_ry2(){return ry2;}
	float get_rz2(){return rz2;}

        
	//Metodos
   //     static void VRPN_CALLBACK handle_tracker_pos_quat (void *userdata, const vrpn_TRACKERCB t);
	void InicializarPolhemus();
	void  DesconectarPolhemus();
	void  ActualizarDatos();
        
};
#endif

